<?php
include '../class/class.user.php';
include '../class/class.kewenangan.php';
include '../class/class.kanwil.php';

if(isset($_REQUEST['list_user'])){
	session_start();
	$id_user=$_SESSION['id_user'];
	$id_kewenangan=$_SESSION['id_kewenangan'];
	$user=new User();
	$user->id_user=$id_user;
	$userDao= new UserDao();

	$usernya=$userDao->getUserById($user);

	$kewenanganDao=array();
	$userDaoNip=array();
	$kanwilDao=array();

	$data=false;
	
	if($usernya!=false){
		
			$kewenanganDao=new kewenanganDao();
			$userDaoNip= new UserDao();
			//$kanwilDao[$i]=new KanwilDao();
			$data=array(
				'id_user' => $usernya['id_user'],
				//'kanwil' => $kanwilDao[$i]->getNmKanwil($row['kdkanwil']),
				'nip'=> $usernya['nip'],
				//'id_parent_user' => $userDaoNip[$i]->getNip($row['id_parent_user']),
				'id_kewenangan' => $kewenanganDao->getKewenangan($usernya['id_kewenangan']),
				'status_aktif' => $usernya['status'],
			);

	}
	echo json_encode($data);
}

if(isset($_REQUEST['data_user'])){
	
	$nip_user=$_REQUEST['nip'];
	
	$user=new User();
	$user->nip=$nip_user;
	$userDao= new UserDao();

	$usernya=$userDao->getUser($user);

	$kewenanganDao=array();
	$userDaoNip=array();
	$kanwilDao=array();

	$data=false;
	
	if($usernya!=false){
		
			$kewenanganDao=new kewenanganDao();
			$userDaoNip= new UserDao();
			//$kanwilDao[$i]=new KanwilDao();
			$data=array(
				'id_user' => $usernya['id_user'],
				//'kanwil' => $kanwilDao[$i]->getNmKanwil($row['kdkanwil']),
				'nip'=> $usernya['nip'],
				//'id_parent_user' => $userDaoNip[$i]->getNip($row['id_parent_user']),
				'id_kewenangan' => $kewenanganDao->getKewenangan($usernya['id_kewenangan']),
				'status_aktif' => $usernya['status'],
			);

	}
	echo json_encode($data);
}

?>